package sctu.edu.java.year2016.team03.liyouhong.day20160607.chapter15_2;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by Administrator on 2016/6/7 0007.
 * 2.尝试开发一个窗体，在窗体中有两个按钮，一个是开始按钮，一个是结束按钮，当单击开始按钮时，在控制台
 * 中持续打印一句话，当用户单击停止按钮时，控制台结束打印。
 */
public class Window extends JFrame {
    public void CreateJFrame(String title) {


        JFrame jf = new JFrame(title);
        Container container = jf.getContentPane();
        container.setLayout(new GridLayout(1,2,10,10));
        jf.setSize(500, 300);
        jf.setVisible(true);

        JButton jb = new JButton("开始");
        JButton jb2 = new JButton("结束");
        jb.setHideActionText(true);

        jb.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
               /* Thread t = new Thread(new Runnable() {
                    public void run() {
                        int count = 0;
                        while (count < 10) {
                            System.out.println("dayin");

                        }
                    }
                });
                new Thread().start();*/
                System.out.println("123");
            }
        });
        container.add(jb);
        container.add(jb2);

    }

    public static void main(String[] args) {
        new Window().CreateJFrame("用户窗口");
    }
}
